/*
 * Created on 2006-2-10
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.hitrust.gs.action;

import java.util.ArrayList;
import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.lib.GSLogWriter;
import com.hitrust.gs.service.GSBaseAction;
import com.hitrust.gs.service.GSBaseForm;
import com.hitrust.gs.util.exception.GSException;
import com.hitrust.gs.bean.GSOperatorBean;
import com.hitrust.gs.business.*;
/**
 * @author simonyi
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class GSOperatorFuncResetAction extends GSBaseAction {

    public String execute(GSBaseForm aForm) throws Exception {
    
        GSOperatorBean operatorBean = (GSOperatorBean)aForm.getSession().getAttribute(GSBaseConstants.LOGIN);
        
        String[] strs1 = aForm.getRequest().getParameterValues("chkbox1");
        String[] strs2 = aForm.getRequest().getParameterValues("chkbox2");
        
        String operId = (String)aForm.getRequest().getParameter("operid");
        
        GSOperatorProcessor oproc = new GSOperatorProcessor();
        try{
            oproc.setOperatorFunc(operId,strs1,strs2,operatorBean);            
        }catch(GSException e){
            GSLogWriter.error(this,e.toString());
            aForm.getRequest().setAttribute("action","A400601.do");
            throw e;
        }
        
        aForm.getRequest().setAttribute("message","操作员权限设置成功!");
        aForm.getRequest().setAttribute("backstep","0");
        GSOrgProcessor processer = new GSOrgProcessor ();
        GSOrganizationProcessor orgp = new GSOrganizationProcessor();
        //if(aForm.getSession().getAttribute("organdaddr") == null){
            ArrayList ary = processer.getOperOrgAndSubOrg(operatorBean.getGs_oper_org_id());
            aForm.getSession().setAttribute("orglist",ary);
            ArrayList organdoper = orgp.getOrgAndOper();
            aForm.getRequest().setAttribute("organdoper",organdoper);
        aForm.getRequest().setAttribute("requery","true");
        return GSBaseConstants.FORWARD_SUCCESS;
    }
}
